package com.cz.background.common.dto;




public class ResponseResult<T> {
    private Integer code; // 状态码
    private String msg; // 消息
    private T data; // 数据

    public ResponseResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResponseResult(String msg, T data) {
        this.msg = msg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    // 成功响应的静态工厂方法
    public static <T> ResponseResult<T> success(String msg,T data) {
        return new ResponseResult<>(msg, data);
    }

    public static <T> ResponseResult<T> success(Integer code, String msg,T data) {
        return new ResponseResult<>(code,msg, data);
    }

    // 失败响应的静态工厂方法
    public static <T> ResponseResult<T> failure(String msg,T data) {
        return new ResponseResult<>(msg, data);
    }

}

